package io.finer.erp.jeecg.bas.service;

import java.util.Collection;
import java.util.List;

import io.finer.erp.jeecg.stock.vo.SumQtyVo2;
import org.jeecg.common.api.vo.Result;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;

import io.finer.erp.jeecg.bas.entity.BasMaterial;
import io.finer.erp.jeecg.stock.entity.StkInventory;
import io.finer.erp.jeecg.stock.entity.StkIoBill;
import io.finer.erp.jeecg.stock.entity.StkIoBillEntry;
import io.finer.erp.jeecg.stock.entity.StkMaterielStorage;
import io.finer.erp.jeecg.stock.vo.ScanIO;
import io.finer.erp.jeecg.stock.vo.SumQtyVo;

/**
 * @Description: 物料
 * @Author: jeecg-boot
 * @Date:   2020-08-25
 * @Version: V1.0
 */
/**
 * @ClassName IBasMaterialService
 * @Description 
 * @author duanyong
 * @Date 2020-08-31 11:44:22
 * @version 1.0.0
 */
public interface IBasMaterialService extends IService<BasMaterial> {
	/**
	 ** @Description: 添加生成物料编码的方法
	 * @Author: duany
	 * @Date:   2020-08-15
	 */
	BasMaterial getMaterialCode(String categoryId);
	
	public List<BasMaterial> selectMaterialByCategoryId(String categoryId);
	
	public List<BasMaterial> selectDistinctMaterialByCategoryId(String categoryId);
	
	
	/**
	 * @Description 停止预警
	 * @param idList
	 * @param result
	 * @return
	 * Create at: 2020-08-26 10:16:27
	 * @author: duanyong
	 * Revision:
	 *    2020-08-26 10:16:27 - first revision by duanyong
	 *        
	 */
	Result<Object> stopWarning(List<String> idList, Result<Object> result);
	
	
	/**
	 * @Description 批量生成物料
	 * @param categoryId
	 * @param number
	 * @return
	 * Create at: 2020-08-31 11:44:31
	 * @author: duanyong
	 * Revision:
	 *    2020-08-31 11:44:31 - first revision by duanyong
	 *        
	 */
	Result<?> batchAdd(String categoryId, Integer number, String userName);
	
	Result<?> batchAdd(String categoryId, Integer number);
	
	/**
	 * @Description 根据编码查询物料
	 * @param code
	 * @return
	 * Create at: 2020-10-07 11:39:14
	 * @author: duanyong
	 * Revision:
	 *    2020-10-07 11:39:14 - first revision by duanyong
	 *        
	 */
	BasMaterial getMaterialByCode(String code);

	/**
	 * @Description 获取物料的供应商
	 * @param suplierId
	 * @param categoryId
	 * @return
	 * Create at: 2020-10-07 11:39:01
	 * @author: duanyong
	 * Revision:
	 *    2020-10-07 11:39:01 - first revision by duanyong
	 *        
	 */
	List<String> getSuplierMaterialId(String suplierId, String categoryId);
	
	/**
	 * @Description 生成物料编码
	 * @param categoryCode
	 * @return
	 * Create at: 2020-10-07 11:38:43
	 * @author: duanyong
	 * Revision:
	 *    2020-10-07 11:38:43 - first revision by duanyong
	 *        
	 */
	public String getCode(String categoryCode);
	
	List<BasMaterial> getByIds(Collection<String> ids);
	
	/**
	 * @Description 生成条码图片并返回地址
	 * @param code
	 * @return
	 * Create at: 2020-10-17 13:07:33
	 * @author: duanyong
	 * Revision:
	 *    2020-10-17 13:07:33 - first revision by duanyong
	 *        
	 */
	String createCodeImg(String code);

	/**
	 * @Description 根据编码集合查询物料
	 * @param codes
	 * @return
	 * Create at: 2020-10-19 17:06:13
	 * @author: duany
	 * Revision:
	 *    2020-10-19 17:06:13 - first revision by duany
	 *        
	 */
	List<BasMaterial> getByCodes(List<String> codes);

	/**
	 * @Description 辅料入库前的方法，将物料信息存到临时表，并且返回要打印的信息
	 * @param batchCategoryId
	 * @param batchNum
	 * @param userName
	 * @param model
	 * @return
	 * Create at: 2020-10-30 09:53:26
	 * @author: duany
	 * Revision:
	 *    2020-10-30 09:53:26 - first revision by duany
	 *        
	 */
	Result<?> batchAddAccessories(String batchCategoryId, Integer batchNum, String userName, String model);

	/**
	 * @Description 根据分类查询一个物料
	 * @param bcpID
	 * @return
	 * Create at: 2020-11-05 11:35:04
	 * @author: duany
	 * Revision:
	 *    2020-11-05 11:35:04 - first revision by duany
	 *        
	 */
	BasMaterial getOneMaterialByCategory(String bcpID);

	/**
	 * @Description 根据分类ID查询库存大于0的物料ID
	 * @param categoryId
	 * @return
	 * Create at: 2020-11-17 09:31:52
	 * @author: duany
	 * Revision:
	 *    2020-11-17 09:31:52 - first revision by duany
	 *        
	 */
	List<String> getInventoryMaterialIdsByCategory(String categoryId);

	void changeMaterialCPCategory(StkIoBill stkIoBill, List<StkIoBillEntry> stkIoBillEntryList);
	
	/**
	 * @Description 根据分类ID创建一个物料
	 * @param categoryId
	 * @return
	 * Create at: 2020-11-24 17:23:28
	 * @author: duany
	 * Revision:
	 *    2020-11-24 17:23:28 - first revision by duany
	 *        
	 */
	public BasMaterial createMaterialByCategory(String categoryId);

	/**
	 * @Description PDA设备传入时批量添加物料
	 * @param scanIo
	 * @return
	 * Create at: 2020-11-26 09:42:34
	 * @author: duany
	 * Revision:
	 *    2020-11-26 09:42:34 - first revision by duany
	 *        
	 */
	Result<?> batchAdd(ScanIO scanIo);

	/**
	 * @Description 根据物料名称查询一个物料ID
	 * @param materialName
	 * @return
	 * Create at: 2020-12-01 09:19:52
	 * @author: duany
	 * Revision:
	 *    2020-12-01 09:19:52 - first revision by duany
	 *        
	 */
	String getOneMaterialIdByName(String materialName);

	/**
	 * @Description 根据分类ID查询物料
	 * @param categoryId
	 * @return
	 * Create at: 2020-12-10 09:57:48
	 * @author: duany
	 * Revision:
	 *    2020-12-10 09:57:48 - first revision by duany
	 *        
	 */
	List<BasMaterial> getByCategoryId(String categoryId);


	Page<StkMaterielStorage> getMaterials(IPage<StkMaterielStorage> page,String warehouseId,String parameter,String materialCode,
										  String width_begin,String width_end,String length_begin,String length_end,String order);

	
	List<StkMaterielStorage> getMaterialsCount(String warehouseId,String parameter,String materialCode,
			  String width_begin,String width_end,String length_begin,String length_end,String order);
	
	/**
	 * @Description 给物料维护配方
	 * @param materialId
	 * @param fomulaId
	 * @return
	 * Create at: 2021-02-04 14:09:27
	 * @author: duany
	 * Revision:
	 *    2021-02-04 14:09:27 - first revision by duany
	 *
	 */
	Result<?> setMaterialFomula(String materialId, String fomulaId);

	Page<StkMaterielStorage> countMateriels(Page<StkMaterielStorage> page, StkMaterielStorage storage);
	
	IPage<StkInventory> getSumQtyDetail(Page<StkInventory> page, StkMaterielStorage storage);

	List<SumQtyVo> countMaterielsXls(String materialId, String pid,String materialName);

	List<SumQtyVo2> countMaterielsXls2(String materialId, String pid, String materialName);
	
	/**
	 * @Description 根据物料分类id查询不在废品库和成品库的实时库存物料id
	 * @param categoryId
	 * @return
	 * Create at: 2021-06-23 11:45:07
	 * @author: xzs
	 * Revision:
	 *    2021-06-23 11:45:07 - first revision by xzs
	 *
	 */
	List<String> getInvenMaterialIdsByCateId(String categoryId);

	BasMaterial getPurchaseMaterial(String materialId);
}
